<template>
	<view class="cent" style="height: 100vh;background-color: aliceblue;">
			<u-tabs :list="list1" @change="change"></u-tabs>
			<view class="pubu">
				<view @click="touch" class="item" v-for="(item,index) in community">
					<image :src="baseUrl+item.community_img" mode="widthFix"></image>
					<view class="" style="align-items: center; display: flex;justify-content: space-around;">
						<image style="width: 70rpx;border-radius: 50%;" :src="baseUrl+item.author_img" mode="widthFix"></image>
						<uni-title class="text" style="text" type="h2" :title="item.author" color="#027fff"></uni-title>
					</view>
				</view>
			</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl:'http://127.0.0.1:8081/',
				list1: [{
				      name: '关注',
				        }, {
				            name: '推荐',
				        }, {
				            name: '电影'
				        }, {
				            name: '科技'
				        }, {
				            name: '音乐'
				        }, {
				            name: '美食'
				      }],
						communitycategory:[],
						community:[]
			}
			
		},
		onLoad() {
			this.getcommunity()
		},
		methods: {
			shuffle1(arr) {
			    return arr.sort(() => 0.5 - Math.random())
			},
			async getcommunity(){
				const data1=await this.$request.community()
				this.community=data1.data.data
				this.shuffle1(this.community)
				console.log(data1)
				const data=await this.$request.getcommunitycategory()
				this.communitycategory=data.data.data
				this.list1.forEach((item,index)=>{
					item.name=this.communitycategory[index].category_name
				})
			},
			touch(){
				uni.navigateTo({
					url:"/pages/community/communitinfo"
				})
			},
			click1(item) {
				
			    console.log('item', item);
			}
		}
	}
</script>

<style>
	.item{
		width: 100%;
		background-color: white;
		border-radius: 10px;
		margin-bottom: 10px;
	}
	.text{
		width: 100%;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	image{
			width: 100%;
	}
	.pubu{
		margin: 10px 10px;
		column-count: 2;
		column-gap: 10px;
		height: 1000vh;
	}
	.cent{
		width: 98%;
		margin: 0px auto;
	}

</style>
